package com.yitong.equipment.ui.adapter

import android.graphics.Color
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.yitong.equipment.R

class MallAllClassifyTitleAdapter(data: MutableList<String>? = null) : BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_mall_all_classify, data) {
    private var checkedPosition = 0
    fun setCheckedPosition(checkedPosition: Int) {
        this.checkedPosition = checkedPosition
        notifyDataSetChanged()
    }

    override fun convert(holder: BaseViewHolder, item: String) {
        var tv_title = holder.getView<TextView>(R.id.tv_title)
        tv_title.setText(item)
        if (holder.bindingAdapterPosition == checkedPosition) {
            holder.itemView.setBackgroundColor(Color.parseColor("#f3f3f3"))
            tv_title.setTextColor(Color.parseColor("#0068cf"))
        } else {
            holder.itemView.setBackgroundColor(Color.parseColor("#FFFFFF"))
            tv_title.setTextColor(Color.parseColor("#1e1d1d"))
        }
    }

}